//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.controller
{
	import mx.managers.PopUpManager;
	
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
	
	import reader.events.BlogSourceEvent;
	import reader.model.IDataProxy;
	import reader.model.vo.TitleWindowVO;
	import reader.view.components.AddSubscribePanel;

	public class AddSubscribeCommand extends SimpleCommand implements ICommand
	{
		//////////////////////////////////////////////////////////////////////////////
		//private variables
		private var dataProxy:IDataProxy;
		
		//////////////////////////////////////////////////////////////////////////////
		//methods
		
		override public function execute(notification:INotification):void
		{
			var titleWindowVO:TitleWindowVO = notification.getBody() as TitleWindowVO;
			var panel:AddSubscribePanel = AddSubscribePanel(PopUpManager.createPopUp(titleWindowVO.parent, AddSubscribePanel, true));
			PopUpManager.centerPopUp(panel);
			panel.addEventListener(BlogSourceEvent.SOURCE_CREATE, onSubScribeLoad_handler);
		}
		
		private function onSubScribeLoad_handler(e:BlogSourceEvent):void
		{
			dataProxy.addSubscribe(e.blogSource);
		}
	}
}